/*
    This file is part of Epoch <http://code.google.com/p/epoch/>.
    
    Copyright (C) 2011  Adam Meily <meily.adam@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/


#include "Request.h"

Request::Request() : Message(), m_method(InvalidMethod)
{

}

Request::Request(const QStringList& input): Message(input)
{
    parseMethod();
}


Request::Request(const Request& other) : Message(other)
{

}

Request::~Request()
{

}

void Request::parseMethod()
{
    Method m = InvalidMethod;
    if(operation() == "get-cert")
        m = GetCert;
    else if(operation() == "get-delta")
        m = GetDelta;
    else if(operation() == "get-ls")
        m = GetListing;
    else if(operation() == "get-handshake")
        m = Handshake;
    m_method = m;
}


Request& Request::operator=(const Request& other)
{
    return *this;
}

bool Request::isNull() const
{
    return m_method == InvalidMethod;
}

Request::Method Request::method() const
{
    return m_method;
}

void Request::method(Request::Method method)
{
    m_method = method;
    setOperation();
}

void Request::setOperation()
{
    QString op;
    if(m_method == Handshake)
        op = "get-handshake";
    else if(m_method == GetCert)
        op = "get-cert";
    else if(m_method == GetDelta)
        op = "get-delta";
    else if(m_method == GetListing)
        op = "get-ls";
    
    operation(op);
}



